<extend name="./public/frame.html"/>
<block name="content">
    <blockquote class="layui-elem-quote search">
        <div class="layui-inline">
            <input type="text" lay-verify="required|title" required placeholder="请输入车牌号"  class="layui-input" id="car_plate">
        </div>
        <div class="layui-inline">
            <input type="text" lay-verify="required|title" required placeholder="请输入手机号"  class="layui-input" id="driver_phone">
        </div>
        <div class="layui-inline">
            <input type="text" lay-verify="required|title" required placeholder="请输入司机姓名"  class="layui-input" id="driver_name">
        </div>
        <div class="layui-inline">
            <select name="province_id" id="province_id" class="layui-input" lay-filter="province" style="width: 150px;" onclick="getProvinceList();">
                <option value="">请选择认证省份</option>
                <?php foreach($provinceList as $key=>$value):?>
                <option value="<?php echo $value['region_id'];?>"><?php echo $value['region_name'];?></option>
                <?php endforeach;?>
            </select>
        </div>
        <div class="layui-inline">
            <select name="city_id" id="city_id" class="layui-input" lay-filter="city_id" style="width: 150px;">
                <option value="">请选择认证城市</option>
            </select>
        </div>
        <div class="layui-inline">
            <button class="layui-btn" id="submit" data-type="search">搜索</button>
        </div>
    </blockquote>
    <table class="layui-table" lay-filter="authT" id="authT"></table>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="auth">资料审核</a>
    </script>

    <script type="application/javascript">
        layui.use(['table','laytpl','laydate'], function () {
            var table = layui.table
                ,laydate = layui.laydate;
            lay('.date').each(function(){
                laydate.render({
                    elem: this
                    ,type: 'date'
                    ,trigger: 'click'
                });
            });
            var tableIns = table.render({
                elem:"#authT",
                url:"{:U('indexCheck')}",
                cols: [[
                    {title:"ID",field:'car_id', width:100,align:'center'},
                    {title:"姓名",field:'driver_name', width:100,align:'center'},
                    {title:"手机号",field:'driver_phone', width:120,align:'center'},
                    {title:"车牌号",field:'car_plate', width:100,align:'center'},
                    {title:"车辆品牌",field:'car_brand', width:100,align:'center'},
                    {title:"车辆型号",field:'car_model', width:100,align:'center'},
                    {title:"颜色",field:'color', width:80,align:'center'},
                    {title:"车辆注册时间",field:'register_at', width:120,align:'center'},
                    {title:"证书提交时间",field:'taxi_add_time', width:160,align:'center'},
                    {title:"证书状态",field:'certificateStatus', width:100,align:'center'},
                    {title:"认证省",field:'region_name_province', width:100,align:'center'},
                    {title:"认证市",field:'region_name_city', width:100,align:'center'},
                    {title:"保单提交时间",field:'commerceinsurance_add', width:160,align:'center',align:'center'},
                    {title:"保单状态",field:'insuranceStatus', width:100,align:'center',align:'center'},
                    {title:"失败原因",field:'taxi_reason', width:220,align:'center'},
                    {title:"操作",toolbar: '#barDemo',width:100,fixed:'right',align:'center'}
                ]],
                page:true,
                limit:10,
                where:{'checkType':1,driver_type : "{$driver_type}"},
                done: function(res, curr, count){
                    _cur_page =curr;
                    _cur_limit =res['limit'];
                }
            });
            //监听工具条
            table.on('tool(authT)', function (obj) {
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的DOM对象
                var car_id = data.car_id;
                if(layEvent === 'auth') {
                    //iframe层
                    layer.open({
                        type: 2,
                        title: '车主资料审核',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:U("check_auth","car_id=")}' + car_id, //iframe的url
                    });
                }
            });
            var $ = layui.jquery, active = {
                search: function () {
                    var car_plate = $('#car_plate').val();
                    var driver_phone = $.trim($('#driver_phone').val());
                    var reset = $('#reset');
                    var checkType = 1;
                    var province_id = $("#province_id").val();
                    var city_id = $("#city_id").val();
                    var driver_name=$("#driver_name").val();
                    var driver_type = "{$driver_type}";
                    tableIns.reload({
                        url: '{:U("indexCheck")}',
                        where: {
                            car_plate : car_plate,
                            driver_phone : driver_phone,
                            checkType:checkType,
                            province_id : province_id,
                            city_id : city_id,
                            driver_name:driver_name,
                            driver_type : driver_type
                        } //设定异步数据接口的额外参数
                    });
                }
            };
            $('.layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
        function getProvinceList(){
            $("#city_id").empty();
            $("#city_id").append('<option value=>请选择认证城市</option>');
            var province_id = $("#province_id").val();
            $.ajax({
                url:'{:url("/admin/Franchisee/cityList")}',
                async:true,
                //dataType:'json',
                type:'post',
                data:{'province_id':province_id},
                success:function(res){
                    $("#city_id").append(res);
                },
                error:function(e){
                    layer.msg('请求错误');return false;
                }
            })
        };
        $('#driver_name').bind('keypress',function(event){
            if(event.keyCode == "13"){
                $("#submit").click();
            }
        });
    </script>
</block>
